/**
 * 
 */
package com.manage.action;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;


import com.action.AbstractAction;
import com.manage.cache.ThreePayProvidersManager;
import com.manage.model.ThreePayProviders;
import com.util.Util;


public class ThreePayProvidersAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	public ThreePayProvidersAction()
	{
		logger = Logger.getLogger(this.getClass());
	}
	
	public String execute()
	{
		return SUCCESS;
	}

	private List<ThreePayProviders> list;
	private ThreePayProviders       model;
	private String        type;
	
	public String list()
	{
		logger.debug("list SdkProviders");
		list = ThreePayProvidersManager.getInstance().getThreePayProviders();
		return SUCCESS;
	}
	
	public String show()
	{
		if (model.getId() >= 0)
		{
			model = ThreePayProvidersManager.getInstance().getThreePayProviders(model.getId());
			type = "update";
		}
		else
		{
			model.setAccessdate(Util.dateToString(new Date(),"yyyy-MM-dd"));
			model.setId(-1);
			type = "insert";
		}

		return SUCCESS;
	}
	
	public String save()
	{
		if(type.equals("insert"))
		{
			model.setCreatedate(Util.dateToString(new Date()));
			model.setCreateuser(operator.getName());
		}
		ThreePayProvidersManager.getInstance().saveThreePayProviders(operator, type, model);
		return SUCCESS;
	}

	public List<ThreePayProviders> getList() {
		return list;
	}

	public void setList(List<ThreePayProviders> list) {
		this.list = list;
	}

	public ThreePayProviders getModel() {
		return model;
	}

	public void setModel(ThreePayProviders model) {
		this.model = model;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
